package com.acme.bankapp.service.bank;

import java.io.FileNotFoundException;
import java.io.IOException;

import com.acme.bankapp.domain.bank.Bank;

public class BankApplication {	
		
	public static void main(String[] args) throws ClassNotFoundException {
		
		if(args.length < 4) {
			System.out.println("the wrong input data");
			return;
		}
		if (!args[0].equals("-loadfeed")) {
			System.out.println("not a -loadfeed");
			return;
		}
		
		if (!args[2].equals("-loadbank")) {
			System.out.println("not a -loadbank");
			return;
		}
				
		Bank SberBank = new Bank();
		Bank serialBank;
		try {
			BankDataLoaderService bs = new BankDataLoaderService(args[1], args[3]);			
			bs.bankLoad(SberBank);
									
			bs.saveBank(SberBank);
			serialBank = bs.readBank();
			
			System.out.println("**************after reconstruction**********************");
			
			System.out.println(serialBank);
		}
		catch (FileNotFoundException e) {
			System.out.println("feedfile does not exists");
			return;
		} catch (IOException e) {
			System.out.println("IOexception");
		}		
	}

}
